/*
 * @Author: TJN tjn@246@126.com
 * @Date: 2024-06-21 15:37:10
 * @LastEditors: TJN tjn@246@126.com
 * @LastEditTime: 2024-06-28 13:03:59
 * @FilePath: \hdcms\hdcms-nest\src\auth\auth.controller.ts
 * @Description:
 *
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
 */
import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  UseGuards,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import RegisterDto from './dto/reigster.dto';
import LoginDto from './dto/login.dto';
import { AuthGuard } from '@nestjs/passport';
import { CurrentUser } from './current-user.decorator';
import { User } from '@prisma/client';

@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  // 注册
  @Post('register')
  register(@Body() dto: RegisterDto, ValidatePipeCustom) {
    return this.authService.register(dto);
  }

  // 登陆
  @Post('Login')
  login(@Body() dto: LoginDto) {
    console.log(dto);

    return this.authService.login(dto);
  }

  @Get('test')
  @UseGuards(AuthGuard('jwt'))
  test(@CurrentUser() user: User) {
    return user;
  }
}
